package com.example.innovate.service.impl;

import com.example.innovate.domain.SuperAdminInfoDO;
import com.example.innovate.domain.SuperAdminInfoDOExample;
import com.example.innovate.mapper.SuperAdminInfoDOMapper;
import com.example.innovate.service.SuperAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class SuperAdminImpl implements SuperAdminService {

    @Autowired
    SuperAdminInfoDOMapper superAdminInfoDOMapper;

    @Override
    public SuperAdminInfoDO getAdminByName(String username) {
        SuperAdminInfoDOExample superAdminInfoDOExample = new SuperAdminInfoDOExample();
        superAdminInfoDOExample.createCriteria().andAdminUserNameEqualTo(username);
        List<SuperAdminInfoDO> list = superAdminInfoDOMapper.selectByExample(superAdminInfoDOExample);
        if(list.isEmpty()){
            return null;
        }
        else{
            return list.get(0);
        }
    }

    @Override
    public void update(SuperAdminInfoDO superAdminInfoDO) {
        superAdminInfoDOMapper.updateByPrimaryKeySelective(superAdminInfoDO);

    }
}
